{% extends 'window.twig' %}
{% block body %}
    <div class="admin-main-container">
        <form action="user.add?act={{ act }}" method="post" class="form-horizontal data-view data-validate" post-type="ajax">
            {% if act == 'update' %}
                <input type="hidden" name="uid" value="{{ user.uid }}"/>
            {% endif %}
            <div class="with-padding">
                <div class="form-item">
                    <div class="item-label">登录用户名
                        <span class="check-tips">
                            （{% if act == 'update' %}不允许修改登录名{% else %}登录名唯一不能重复{% endif %}）
                        </span>
                        <label class="error" for="login_name"></label>
                    </div>
                    <div class="controls">
                        <input type="text" class="form-control" name="login_name"
                               remote-url="user.exists{% if act == 'update' %}?uid={{ user.uid }}{% endif %}" {% if act == 'update' %}readonly="readonly" {% endif %}
                                data-rules="required remote" data-message-required="请填写登录用户名" value="{{ user.login_name }}">
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">登录密码
                        <span class="check-tips">{{ act == 'update' ?'(不修改密码则不不填写)':'' }}</span>
                        <label class="error" for="login_pass"></label>
                    </div>
                    <div class="controls">
                        <input type="password" class="form-control" name="login_pass" value="" id="login_pass"
                               {% if act == 'insert' %}data-rules="required" data-message-required="请填写登录密码"{% endif %}>
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">再次输入密码
                        <label class="error" for="login_pass_re"></label>
                    </div>
                    <div class="controls">
                        <input type="password" class="form-control" name="login_pass_re" value=""
                               data-rules="{% if act == 'insert' %}required{% endif %} equalTo" data-equal-to="#login_pass"
                               data-message-required="请再次填写登录密码" data-message-equalTo="两次填写的密码不一致">
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">用户昵称</div>
                    <div class="controls">
                        <input type="text" class="form-control" name="nick_name" value="{{ user.nick_name }}"
                               placeholder="做一个`名`人吧">
                    </div>
                </div>
            </div>

            <div class="form-item with-padding" style="margin-top: 10px;">
                <button class="btn btn-primary" type="submit">确 定</button>
                <a class="btn btn-info" href="javascript:history.back();">返 回</a>
            </div>
        </form>
    </div>
{% endblock %}